package tablegenerator;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Map;

import parser.TrecEvalParser;

public class QueryPerformanceGraphGenerator {

	public static void main(String[] args) throws FileNotFoundException
	{
		String path = "D:\\ameer\\result\\ubuntu";
		String[] methods = {"M.eval","I-M.combsum.eval","Title-I-M.combsum.eval", "I-M-VD.combsum.eval","Title-I-M-VD.combsum.eval"};
		String[] qnos = {"1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25"};
		
		System.out.println("============ MAP ===================================");
		generateLine(path,methods, "map", qnos);
		
		System.out.println("============ MRR ===================================");
		generateLine(path,methods, "recip_rank", qnos);
		
		System.out.println("============ P.10 ===================================");
		generateLine(path,methods, "P_10", qnos);
		
		System.out.println("============ ndcg_cut_10 ===================================");
		generateLine(path,methods, "ndcg_cut_10", qnos);
		
		
	}
	
	public static void generateLine(String path, String method, String measure) throws FileNotFoundException
	{
		Map<String,Map<String,Double>> methodEval = TrecEvalParser.parseMethodEval(new File(path + "\\"+method));
		
		
		for (String qno : methodEval.keySet() )
		{
			if (!qno.equalsIgnoreCase("all"))
			{
				System.out.printf("");
			}
		}
	}
	
	public static void generateLine(String path,String[] methods, String measure, String[] qnos) throws FileNotFoundException
	{
		File[] methodsFiles = new File[methods.length];
		
		for (int i  = 0; i < methods.length; i++)
		{
			methodsFiles[i] = new File(path + "\\" + methods[i]);
		}
		
		Map<String,Map<String,Map<String,Double>>> methodEvals = TrecEvalParser.parseEvaluation(methodsFiles);
		
		System.out.printf("%s, ","Qno");
		
		for (String method : methods)
			System.out.printf("%s, ", method);
		
		System.out.println();
		
		for (String qno : qnos )
		{
			System.out.printf("%s, ",qno);
			for (String method : methods)
				System.out.printf("%.4f, ", methodEvals.get(method).get(qno).get(measure));
			
			System.out.println();
		}
	}
}
